package md.mru.core.dtos;

import javax.persistence.PostPersist;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author sergiu.marin
 * @since 19.05.2014.
 */
public class OrderDto implements BaseDto, Serializable {

    private static final long serialVersionUID = -5281037985070775974L;

    private long id;
    private OrderTypeDto orderType;
    private Integer orderNumber;
    private Date orderDate;
    private Date fromDate;
    private Date toDate;
    private IssuerDto issuer;
    private AdvancementRankDto advancementRank;
    private String ground;
    private String orderText;
    private List<FolderDto> folders = new ArrayList<>();
    private Date createdDate;
    private OrderCourseDto orderCourse;
    private Integer trialPeriod;
    private String transferFrom;
    private Date docDate;
    private String docNumber;
    private String educationInstitutionName;
    private String location;
    private String issuedBy;
    private String reason;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public OrderTypeDto getOrderType() {
        return orderType;
    }

    public void setOrderType(OrderTypeDto orderType) {
        this.orderType = orderType;
    }

    public String getOrderText() {
        return orderText;
    }

    public void setOrderText(String orderText) {
        this.orderText = orderText;
    }

    public List<FolderDto> getFolders() {
        return folders;
    }

    public void setFolders(List<FolderDto> folders) {
        this.folders = folders;
    }

    public FolderDto getFolder() {
        if (folders != null && !folders.isEmpty()) {
            return folders.get(0);
        }
        return null;
    }

    public void setFolder(FolderDto folder) {
        if (folders == null) {
            folders = new ArrayList<>();
        }
        folders.add(folder);
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    @PostPersist
    public void setCreatedDate(Date createdDate) {
        this.createdDate = Calendar.getInstance().getTime();
    }

    public Integer getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(Integer orderNumber) {
        this.orderNumber = orderNumber;
    }

    public Date getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(Date orderDate) {
        this.orderDate = orderDate;
    }

    public Date getDocDate() {
        return docDate;
    }

    public void setDocDate(Date docDate) {
        this.docDate = docDate;
    }

    public Date getFromDate() {
        return fromDate;
    }

    public void setFromDate(Date fromDate) {
        this.fromDate = fromDate;
    }

    public Date getToDate() {
        return toDate;
    }

    public void setToDate(Date toDate) {
        this.toDate = toDate;
    }

    public IssuerDto getIssuer() {
        return issuer;
    }

    public void setIssuer(IssuerDto issuer) {
        this.issuer = issuer;
    }

    public String getGround() {
        return ground;
    }

    public void setGround(String grounds) {
        this.ground = grounds;
    }

    public AdvancementRankDto getAdvancementRank() {
        return advancementRank;
    }

    public void setAdvancementRank(AdvancementRankDto advancementRank) {
        this.advancementRank = advancementRank;
    }

    public OrderCourseDto getOrderCourse() {
        return orderCourse;
    }

    public void setOrderCourse(OrderCourseDto orderCourse) {
        this.orderCourse = orderCourse;
    }

    public Integer getTrialPeriod() {
        return trialPeriod;
    }

    public void setTrialPeriod(Integer trialPeriod) {
        this.trialPeriod = trialPeriod;
    }

    public String getTransferFrom() {
        return transferFrom;
    }

    public void setTransferFrom(String transferFrom) {
        this.transferFrom = transferFrom;
    }

    public String getDocNumber() {
        return docNumber;
    }

    public void setDocNumber(String docNumber) {
        this.docNumber = docNumber;
    }

    public String getEducationInstitutionName() {
        return educationInstitutionName;
    }

    public void setEducationInstitutionName(String educationInstitutionName) {
        this.educationInstitutionName = educationInstitutionName;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getIssuedBy() {
        return issuedBy;
    }

    public void setIssuedBy(String issuedBy) {
        this.issuedBy = issuedBy;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

}
